package com.xjtu.platform.security.forgetPwd.dao;

import com.xjtu.platform.security.forgetPwd.Email;
import com.xjtu.platform.security.forgetPwd.ForgetPwdDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ForgetPwdDao {
    @Select("select email from user where user_id=#{user_id}")
    List<Email> getEmail(ForgetPwdDto forgetPwdDto);

    @Update("update user set flag=#{code} where user_id=#{dto.user_id}")
    void insertFlag(@Param("dto") ForgetPwdDto forgetPwdDto, @Param("code") int code);

    @Select("select flag from user where user_id=#{user_id}")
    int getCode(ForgetPwdDto forgetPwdDto);

    @Update("update user set user_pwd=#{new_pwd} where user_id=#{user_id}")
    void updatePwd(ForgetPwdDto forgetPwdDto);

    @Select("select time from cache where cache_id=#{user_id}")
    long getCachetime(String user_id);
}
